Merged
Conversation
`SliceRingBuffer` is unsound and has multiple security advisories [1] [2]. There has been no apparent progress on fixes since May 2025 [3]. The crate's large volume of interdependent `unsafe` blocks will likely make it very tricky to maintain. While a memory-mapped deque is a very cool idea, it is time to move on for now. Let's replace `SliceRingBuffer` with a more traditional double-ended queue. These queues don't covert to slice, but we don't really *need* a slice. At present, slice is mostly used to align the end of `Window` (with the most recent samples) to the filter taps. We can do that just as easily with a `DoubleEndedIterator`. * Make `Window` convertible to an iterator of numbers, via `IntoIterator`. Replace all uses of slices with iterators. * Remove slice conversions and accessors from Window. They're still technically accessible via `inner()`, but nothing uses them. [1]: https://rustsec.org/advisories/RUSTSEC-2025-0044 [2]: https://rustsec.org/advisories/RUSTSEC-2020-0158 [3]: LiquidityC/slice_ring_buffer#12
Previously, `FilterCoeff` were stored in reverse order, with feedforward lag 0 stored *last*. This was convenient when `Window` coerced to slice. Now that we iterate over `Window` in reverse order, reversing the filter taps does not serve us. It is also confusing: the taps are in "normal" order in `FilterCoeff::from_slice()`, but later reads via `as_slice()` show them reversed. Ick. Put filter taps in their proper order.
Replace `SliceRingBuffer` with a standard `VecDeque` in our FIR filter `Window` implementation. The crate dependency is dropped.
5549562 to
3d40e65
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SliceRingBufferis unsound and has multiple security advisories 1 2. There has been no apparent progress on fixes since May 2025 3. The crate's large volume of interdependentunsafeblocks will likely make it very tricky to maintain.SliceRingBufferbacks the FIR filterWindow. The slice coercion is used to align the back of theWindow(with the most recent samples) with the FIR filter taps. We don't actually need a slice for this: we can get by with aDoubleEndedIteratorinstead.Make
Windowconvertible to an iterator of numbers, viaIntoIterator. Replace all uses of slices with iterators.Store FIR
FilterCoefftaps in "proper" order, instead of reversed. Since we use iterators instead of slices, reverse-order is no longer convenient.Replace
SliceRingBufferwithstd::collections::VecDeque.Testing indicates that
VecDequemay be up to twice as fast as the previous implementation.Closes #53